package com.bupt.ilink.mapper.userManagement;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bupt.ilink.entity.userManagement.TeamFiles;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface TeamFilesMapper extends BaseMapper<TeamFiles> {

    @Select("SELECT * FROM team_files WHERE group_id = #{groupId} AND team_id = #{teamId}")
    List<TeamFiles> selectByGroupSource(@Param("groupId") Long groupId, @Param("teamId") Long teamId);


    @Select("SELECT tf.file_id, tf.file_name, tf.group_id, tf.team_id " +
            "FROM team_files tf " +
            "JOIN user_connect_teams uct ON tf.group_id = uct.group_id " +
            "WHERE uct.user_id = #{userId} " +
            "AND tf.team_id = #{teamId}")
    List<TeamFiles> getTeamResourcesFiles(@Param("userId") String userId, @Param("teamId") Long teamId);

}